home *** CD-ROM | disk | FTP | other *** search
- property pMySprite, pMyMemNum
- global cBoundSprite, cGridSprite, cGridSpace, cHalfGridSpace, cGroutSprite, cTileLocList, cTileOffset, cFloatSprite, cShadowSprite, cGridHList, cGridVList, gTileTrackList, cRightEdge, cBottomEdge
-
- on new me, mySprite, myMem
- set pMySprite to mySprite
- set pMyMemNum to the number of member myMem
- return me
- end
-
- on dragTile me
- set mH to the mouseH
- set mV to the mouseV
- set HSTART to the locH of sprite pMySprite
- set VSTART to the locV of sprite pMySprite
- set spriteWidth to the width of sprite pMySprite
- set spriteHeight to the height of sprite pMySprite
- if (HSTART - mH) > 0 then
- set H_offset to min(spriteWidth, HSTART - mH)
- else
- set H_offset to max(-spriteWidth, HSTART - mH)
- end if
- if (VSTART - mV) > 0 then
- set V_offset to min(spriteHeight, VSTART - mV)
- else
- set V_offset to max(-spriteHeight, VSTART - mV)
- end if
- set the castNum of sprite cFloatSprite to pMyMemNum
- set the loc of sprite cFloatSprite to the loc of sprite pMySprite
- set the loc of sprite pMySprite to point(-1000, -1000)
- repeat while the stillDown
- set the locH of sprite cFloatSprite to the mouseH + H_offset
- set the locV of sprite cFloatSprite to the mouseV + V_offset
- set the locH of sprite cShadowSprite to the mouseH + H_offset + 16
- set the locV of sprite cShadowSprite to the mouseV + V_offset + 16
- updateStage()
- end repeat
- placeTile(me)
- end
-
- on placeTile me
- if sprite cFloatSprite within cBoundSprite then
- set whichHPos to findPosNear(cGridHList, the locH of sprite cFloatSprite - cHalfGridSpace)
- set whichVPos to findPosNear(cGridVList, the locV of sprite cFloatSprite - cHalfGridSpace)
- set whichH to getAt(cGridHList, whichHPos)
- set whichV to getAt(cGridVList, whichVPos)
- slideIntoPlace(me, whichH, whichV)
- set checkProp to string(whichVPos) & string(whichHPos)
- setAt(gTileTrackList, pMySprite - cTileOffset, checkProp)
- updateStage()
- set the loc of sprite cFloatSprite to point(-1000, -1000)
- set the loc of sprite cShadowSprite to point(-1000, -1000)
- else
- setAt(gTileTrackList, pMySprite - cTileOffset, EMPTY)
- if the locH of sprite cFloatSprite > (cRightEdge - 8) then
- set whichH to cRightEdge
- else
- if the locH of sprite cFloatSprite < -8 then
- set whichH to 0
- else
- set whichH to the locH of sprite cFloatSprite + 8
- end if
- end if
- if the locV of sprite cFloatSprite > (cBottomEdge - 8) then
- set whichV to cBottomEdge
- else
- if the locV of sprite cFloatSprite < -8 then
- set whichV to 0
- else
- set whichV to the locV of sprite cFloatSprite + 8
- end if
- end if
- slideIntoPlace(me, whichH, whichV)
- end if
- puppetSound("Drop")
- updateStage()
- end
-
- on slideIntoPlace me, targetH, targetV
- set deltaH to targetH - the locH of sprite cFloatSprite
- set deltaV to targetV - the locV of sprite cFloatSprite
- set deltaHS to targetH - the locH of sprite cShadowSprite
- set deltaVS to targetV - the locV of sprite cShadowSprite
- repeat with i = 1 to 10
- set comp to 10 - i
- set the locH of sprite cFloatSprite to targetH - (comp * deltaH / 10)
- set the locV of sprite cFloatSprite to targetV - (comp * deltaV / 10)
- set the locH of sprite cShadowSprite to targetH - (comp * deltaHS / 10)
- set the locV of sprite cShadowSprite to targetV - (comp * deltaVS / 10)
- updateStage()
- end repeat
- set the loc of sprite pMySprite to the loc of sprite cFloatSprite
- updateStage()
- end
-